package com.content.view.Frame.InfoTape
{
	import com.content.model.LoadedAssets.FontProxy;
	import com.content.model.LoadedAssets.SkinProxy;
	import com.content.model.OnlineRes.UserVO;
	import com.library.core.IDisposable;
	import com.library.core.UIObject;
	import com.library.utils.TextFieldUtil;
	import com.library.utils.TimeUtil;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;
	
	import gs.TweenLite;
	
	public class InfoTape extends UIObject implements IDisposable
	{
		public static const NAME:String							= 'InfoTape';
		
		public static const SHOW:String							= NAME + "-" + 'Show';
		public static const HIDE:String							= NAME + "-" + 'Hide';
		
		private var _vo:UserVO;
		private var _stageW:int;
		private var _stageH:int;
		
//		private var _bg:Shape;
		private var _bodyHeight:int;
		private var _marginLeft:int;
		private var _marginRight:int;
		private var _cBarWidth:int;
		
		private var _txtInfo:TextField;
		
		public function InfoTape( bodyHeight:int,
								 marginLeft:int,
								 marginRight:int,
								 cBarWidth:int)
		{
			this.visible = false;
			this.alpha = 0;
				
			_bodyHeight = bodyHeight;
			_marginLeft = marginLeft;
			_marginRight = marginRight;
			_cBarWidth = cBarWidth;
			
			_vo = new UserVO();
			
//			_bg = new Shape;
//			addChild(_bg);
			
			_txtInfo = TextFieldUtil.Generate("", 15, 0xffffff, FontProxy.FONT_YAHEI_BOLD); 
			addChild(_txtInfo);
		}
		
		public function SetLayout(sWidth:int, sHeight:int):void{
			_stageW = sWidth;
			_stageH = sHeight;
			// 计算出自己的大小
			var bgWidth:int = sWidth - _marginLeft - _marginRight - _cBarWidth;
			var bgHeight:int = _bodyHeight;
			
//			_bg.graphics.clear();
//			_bg.graphics.beginFill(0xff0000, 0.01);
//			_bg.graphics.drawRect(0,0,bgWidth, bgHeight);
			
			_txtInfo.x = int(bgWidth - _txtInfo.width - 10);
			_txtInfo.y = 1;
		}
		
		/* Event Handler
		 * ------------------------------------------------------------- */
	
		/* Public Method
		 * ------------------------------------------------------------- */
		/* Public Method
		* ---------------------------------------------------- */
		public function InfoUpdate(xml:XML):void{
			var cmdName:String = xml.head.command;
			
			_vo.Number = xml.body.personal.base.info.(@id == "number");
			_vo.Fullname = xml.body.personal.base.info.(@id == "fullname");
			_vo.Gender = xml.body.personal.base.info.(@id == "gender");
			_vo.Birthday = xml.body.personal.base.info.(@id == "birthday");
			_vo.Nationality = xml.body.personal.base.info.(@id == "nationality");
			_vo.School = xml.body.personal.base.info.(@id == "school");
			_vo.SchoolAddress = xml.body.personal.base.info.(@id == "schooladdress");
			_vo.Class = xml.body.personal.base.info.(@id == "class");
			_vo.RegisterDate = xml.body.personal.base.info.(@id == "registerdate");
			_vo.Photo = xml.body.personal.base.info.(@id == "photo");
			
			_txtInfo.text = TimeUtil.GetDateString()+"\t"+ _vo.Class + "  " + _vo.Fullname;
			
			SetLayout(_stageW, _stageH);
		}
		
		public function Show(delay:Number = 0, duration:Number = 1.0):void{		TweenLite.to( this, duration, { autoAlpha: 1, delay: delay } );		}		
		public function Hide():void	{			TweenLite.to( this, .5, { autoAlpha: 0 } );		}
		
		public function Dispose():void
		{
		}
	}
}